<?php
if(!defined('SABLOG_ROOT')) {
	exit('Access Denied');
}

$query = $DB->query("SELECT dateline FROM {$db_prefix}articles WHERE visible = '1' ORDER BY dateline DESC");
$articledb = $arr = $archivedb = array();
while ($article = $DB->fetch_array($query)) {
	$articledb[] = sadate('Y-m',$article['dateline']);
}
unset($article);
$DB->free_result($query);
$arr = array_count_values($articledb);
unset($articledb);
foreach($arr as $key => $val){
	list($y, $m) = explode('-', $key);
	$archivedb[$y][$m] = $val;
}
//哎,为了处理好归档的连接和方便模板直接使用,只有牺牲点效率了.
$tmpdb = array();
foreach($archivedb as $y => $arr){
	if (is_array($arr)) {
		ksort($arr);
		foreach($arr as $m => $num){
			$tmpdb[$y][$m]['url'] = getdatelink($y.$m);
			$tmpdb[$y][$m]['num'] = $num;
		}
	}
}
$archivedb = $tmpdb;
$tmpdb = null;

$pagefile = 'archives';
$options['title'] = settitle('日志归档');

?>